package main

import (
	"log"
	"os"
	"strconv"
)

func main() {
	if os.Getenv("_GRACEFUL_RESTART") == "true" {
		file := os.NewFile(3, "")
		log.Print(file.Fd())
		r := make([]byte, 10)
		file.Seek(0, 0)
		n, e := file.Read(r)
		if nil != e {
			log.Print(n)
		}
		os.Setenv("_GRACEFUL_RESTART", "false")
		return
	}
	os.Setenv("_GRACEFUL_RESTART", "true")

	fileFds := []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()}
	for i := 0; i < 3; i++ {
		f, e := os.Create("test" + strconv.Itoa(i))
		if nil != e {
			log.Print(e.Error())
		}
		f.Write([]byte("hello"))
		f.Sync()
		fileFds = append(fileFds, f.Fd())
		log.Print(f.Fd())
	}
}
